<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
      类型，构造函数，类
      1. 类型本质上就是判断变量或者值是哪个构造函数或者类创建new的
      */

      //完美的判断8大基本数据类型
      console.log(Object.prototype.toString.call(123)); //[object Number]
      console.log(Object.prototype.toString.call("jack")); //[object String]
      console.log(Object.prototype.toString.call(true)); //[object Boolean]
      console.log(Object.prototype.toString.call(null)); //[object Null]
      console.log(Object.prototype.toString.call(undefined)); //[object Undefined]
      console.log(Object.prototype.toString.call(function () {})); //[object Function]
      console.log(Object.prototype.toString.call([])); //[object Array]
      console.log(Object.prototype.toString.call({})); //[object Object]
      console.log(Object.prototype.toString.call(Symbol())); //[object Symbol]

      // 对于自定义对象类型无法判断
      class Person {}
      const p = new Person(); // p Person
      console.log(Object.prototype.toString.call(p)); //[object Object]
    </script>
  </body>
</html>
